﻿using System;
using System.Xml.Linq;
using System.Collections.Generic;
using HigLabo.Net.Extensions;


namespace HigLabo.Net.Twitter
{
    /// <summary>
    /// 
    /// </summary>
    public class RateLimitInfo : ResponseObject
    {
        /// <summary>
        /// 
        /// </summary>
        public String FamilyPath { set; get; }
        /// <summary>
        /// 
        /// </summary>
        public Int32 Remaining { set; get; }
        /// <summary>
        /// 
        /// </summary>
        public Int64 Reset { set; get; }
        /// <summary>
        /// 
        /// </summary>
        public Int32 Limit { set; get; }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsonText"></param>
        public RateLimitInfo(String jsonText)
        {
            this.SetProperty(jsonText);
        }
        /// <summary>
        /// 
        /// </summary>
        /// <param name="jsonText"></param>
        public override void SetProperty(string jsonText)
        {
            String familyPaht = "";
            if (jsonText.IndexOf("\":") - 1 >= 2)
            {
                familyPaht = jsonText.Substring(1, jsonText.IndexOf("\":") - 1);
                jsonText = jsonText.Substring(jsonText.IndexOf("\":") + 2);
            }
            var d = this.SetData(jsonText);
           
            this.FamilyPath = familyPaht;
            this.Remaining = d.ToInt32("remaining") ?? 0;
            this.Reset = d.ToInt64("reset") ?? 0;
            this.Limit = d.ToInt32("limit") ?? 0;

        }
    }
}
